﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ImageCropper
{
    public partial class VerticalGuideline : UserControl, IGuideline
    {
        public event EventHandler Hidden;

        public VerticalGuideline()
        {
            InitializeComponent();
        }

        public void ShowLine()
        {
            this.LayoutRoot.Visibility = System.Windows.Visibility.Visible;
            this._fadeInStory1.Begin();
        }

        public void HideLine()
        {
            _fadeOutStory.Begin();

            if (_fadeInStory1.GetCurrentState() != ClockState.Stopped)
                _fadeInStory1.Stop();

            if (_fadeInStory2.GetCurrentState() != ClockState.Stopped)
                _fadeInStory2.Stop();
        }

        private void _fadeInStory1_Completed(object sender, EventArgs e)
        {
            this._fadeInStory1.Stop();
            this._fadeInStory2.Begin();
        }

        private void _fadeOutStory_Completed(object sender, EventArgs e)
        {
            this._fadeOutStory.Stop();
            this.LayoutRoot.Visibility = System.Windows.Visibility.Collapsed;

            if (Hidden != null)
                this.Hidden(this, EventArgs.Empty);
        }  
    }
}
